package com.itheima.nosql.entity;

import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Arrays;
import java.util.Random;

@Document("user")
public class User {
    @Transient
    private Long id;
    private String name;
    private int age;
    private String[] tags;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String[] getTags() {
        return tags;
    }

    public void setTags(String[] tags) {
        this.tags = tags;
    }

    public static String[] tags(Random random){
        String[] tags = {"土豪","青春","不差钱","呆萌","文艺",
                "小清新","仙女","宅","游戏控","程序猿","二哈",
                "直男","社会人","工作狂","老铁","任性"
        };
        int i = 1+random.nextInt(5);
        String[] rand = new String[i];
        for (int i1 = 0; i1 < i; i1++) {
            rand[i1] = tags[random.nextInt(tags.length)];
        }
        return rand;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {
            System.out.println(Arrays.toString(User.tags(new Random())));
        }
    }
}
